package com.example.rpsm_property.service;

import com.example.rpsm_property.mapper.RoomMapper;
import com.example.rpsm_property.pojo.PageResult;
import com.example.rpsm_property.pojo.Room;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
    public class RoomServiceImpl implements RoomService{
        @Resource
        RoomMapper roomMapper;
        @Override
        public List<Room> roomsOfFloor(Integer floorId) {
            return roomMapper.roomsOfFloor(floorId);
        }
        @Override
        public PageResult<Room> pageOfRoom(Map<String, String> map) {
            PageHelper.startPage(Integer.parseInt(map.get("current"))
                    ,Integer.valueOf(map.get("size")));
            Page<Room> rooms = roomMapper.pageOfRooms(map);
            return PageResult.restPage(rooms);
        }
    @Override
    public int changeRoomStatus(List<Integer> idList, int status)
    {
        return roomMapper.changeRoomStatus(idList,status);
    }
    }

